const fs = require('fs-extra');
const path = require('path');

const dir = process.cwd();

const copys = [
  {
    source: path.join(dir, 'pm2.json'),
    dist: path.join(dir, 'dist/pm2.json')
  },
  {
    source: path.join(dir, 'package.json'),
    dist: path.join(dir, 'dist/package.json')
  }
];

const renames = [
  {
    source: path.join(dir, 'dist'),
    dist: path.join(dir, 'dex-io-cms-server')
  }
]

const main = async () => {
  for (const { source, dist } of copys) {
    await fs.copySync(source, dist);
  }

  for (const { source, dist } of renames) {
    await fs.renameSync(source, dist);
  }
};

main();
